﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Json;

namespace SpaceShooterServer
{
    public static class Helpers
    {
        public static JsonObject GenerateAsteroid()
        {
            var ran = new Random();
            var asteroid = new JsonObject();
            var size = ran.NextDouble() * 50 + 25;
            asteroid["size"] = size;
            asteroid["life"] = 10;
            asteroid["angle"] = 0;
            asteroid["rotation"] = ran.NextDouble() * 6 - 3;
            asteroid["size"] = ran.NextDouble() * 50 + 25;

            if (ran.NextDouble() < 0.5)
            {
                asteroid["x"] = ran.NextDouble() * 800;
                asteroid["y"] = ran.NextDouble() < 0.5 ? -size / 2 : 600 + size / 2;
            }
            else
            {
                asteroid["x"] = ran.NextDouble() < 0.5 ? -size / 2 : 800 + size / 2;
                asteroid["y"] = ran.NextDouble() * 600;
            }

            asteroid["vx"] = ran.NextDouble() * 6 - 3;
            asteroid["vy"] = ran.NextDouble() * 6 - 3;
            return asteroid;
        }
    }
}
